import request from '@/utils/request'

export function login(username, password) {
  return request({
    url: '/user/login',
    method: 'post',
    data: {
      username,
      password
    }
  })
}

//根据token查询用户信息
export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'get'
  })
}

export function register(user) {
  return request({
    url: '/user/register',
    method: 'post',
    data: user
  })
}


export function isAvailableUsername(username) {
  return request({
    url: `/user/avaliable/${username}`,
    method: 'get',
  })
}



